package cn.csc.module.shoppingCard.api.transaction;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.module.shoppingCard.api.transaction.dto.CardTransactionCreateReqDTO;
import cn.csc.module.shoppingCard.api.transaction.dto.CardTransactionRespDTO;
import cn.csc.module.shoppingCard.enums.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.math.BigInteger;
import java.util.List;

/**
 * 购物卡交易记录 feign api
 * @author liuchuang
 * @version 1.0
 * @modify
 * @since 2025/3/11 15:51
 */
@FeignClient(name = ApiConstants.NAME) // TODO fallbackFactory =
@Api(tags = "RPC 服务 - 购物卡交易记录")
public interface CardTransactionApi {

    String PREFIX = ApiConstants.PREFIX + "/shopping-card";

    /**
     * 创建购物卡交易记录
     */
    @PostMapping(value = PREFIX + "/ct/create")
    @ApiOperation("创建购物卡交易记录")
    CommonResult<Boolean> create(@Valid @RequestBody List<CardTransactionCreateReqDTO> list);

    /**
     * 更新交易记录状态
     * 根据交易类型增减购物卡余额
     * @param orderIds 订单ID
     * @return
     */
    @PostMapping(PREFIX + "/ct/updateStatus")
    @ApiOperation("更新交易记录状态")
    CommonResult<Boolean> updateStatus(@RequestParam("orderIds") List<BigInteger> orderIds);
    /**
     * 根据订单Id获取购物卡的使用记录
     * @param orderIds 订单ID
     * @return
     */
    @PostMapping(PREFIX + "/ct/getByOrderIds")
    @ApiOperation("根据订单Id获取购物卡的使用记录")
    CommonResult<List<CardTransactionRespDTO>> getByOrderIds(@RequestParam("orderIds") List<BigInteger> orderIds);


}
